//
// Created by ftd on 2021/8/18.
// 环形缓冲
//

#ifndef DEMO_RING_BUFFER_H
#define DEMO_RING_BUFFER_H
#include <memory>
#include <stdint.h>
#include <stdint.h>

class RingBuffer {
public:
    RingBuffer();
    ~RingBuffer();

    inline void reset() {
        out_ = in_ = 0;
    }

    uint8_t* NewBuffer();

    bool PutData(const void* in_buffer, int len);
    bool GetData(void* out_buffer, int len);

private:
    int64_t in_;
    int64_t out_;
    int64_t buffer_size_;
    std::unique_ptr<uint8_t[]> buffer;
};


#endif //DEMO_RING_BUFFER_H
